import request from '@/utils/request'
import Qs from 'qs'

export function listDistribution(query) {
  return request({
    method: 'get',
    params: {
      _gp: 'admin.distribution',
      _mt: 'list',
      orderBy: 'totalSum',
      ...query
    }
  })
}

export function createDistribution(data) {
  return request({
    method: 'post',
    data: Qs.stringify({
      _gp: 'admin.distribution',
      _mt: 'create',
      ...data
    })
  })
}

export function updateDistribution(data) {
  return request({
    method: 'post',
    data: Qs.stringify({
      _gp: 'admin.distribution',
      _mt: 'edit',
      ...data
    })
  })
}

export function deleteDistribution(id) {
  return request({
    method: 'post',
    data: Qs.stringify({
      _gp: 'admin.distribution',
      _mt: 'delete',
      distributionId: id
    })
  })
}

export function listDistributionStrategy(query) {
  return request({
    method: 'get',
    params: {
      _gp: 'admin.distributionstrategy',
      _mt: 'list',
      ...query
    }
  })
}

export function createDistributionStrategy(data) {
  return request({
    method: 'post',
    data: Qs.stringify({
      _gp: 'admin.distributionstrategy',
      _mt: 'create',
      ...data
    })
  })
}

export function updateDistributionStrategy(data) {
  return request({
    method: 'post',
    data: Qs.stringify({
      _gp: 'admin.distributionstrategy',
      _mt: 'edit',
      ...data
    })
  })
}

export function deleteDistributionStrategy(id) {
  return request({
    method: 'post',
    data: Qs.stringify({
      _gp: 'admin.distributionstrategy',
      _mt: 'delete',
      id
    })
  })
}

export function listDistributionWithdraw(query) {
  return request({
    method: 'get',
    params: {
      _gp: 'admin.distributionwithdraw',
      _mt: 'list',
      ...query
    }
  })
}

export function auditDistributionWithdraw(withdrawId, status) {
  return request({
    method: 'get',
    params: {
      _gp: 'admin.distributionwithdraw',
      _mt: 'audit',
      withdrawId,
      status
    }
  })
}

export function listRankingUser(query) {
  return request({
    method: 'get',
    params: {
      _gp: 'admin.distribution',
      _mt: 'rankingList',
      ...query
    }
  })
}

export function listDistributionDetail(query) {
  return request({
    method: 'get',
    params: {
      _gp: 'admin.distribution',
      _mt: 'detailPage',
      ...query
    }
  })
}
